package cn.matrix42.potoo.format.markdown.element.text.paragraph;

import java.util.ArrayList;
import java.util.List;

import cn.matrix42.potoo.format.markdown.element.MarkdownElement;
import cn.matrix42.potoo.lang.Preconditions;

public class Paragraph extends MarkdownElement {

    private String content;

    public Paragraph() {

    }

    public Paragraph(String content) {
        Preconditions.checkNotNull(content);
        this.content = content;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public List<String> toMarkdownStringList() {
        List<String> list = new ArrayList<>();
        list.add(content);
        list.add(context.getConfig().getEof());
        return list;
    }

    private Paragraph internalNewLine() {
        return new Paragraph(this.content = context.getConfig().getEof());
    }

    public static Paragraph of(String content) {
        return new Paragraph(content);
    }

    public static Paragraph newLine() {
        return new Paragraph().internalNewLine();
    }

}
